package com.lcxw.hxzbadmin.common;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.lcxw.hxzbapi.controller.giftandcubecontroller.CubeRealization;
import com.lcxw.hxzbapi.controller.goodnamecontroller.GoodNameRealization;
import com.lcxw.hxzbapi.controller.incomecontroller.TixianRealization;
import com.lcxw.hxzbapi.controller.membercontroller.MemberRealization;
import com.lcxw.hxzbapi.controller.roomcontroller.Qiniu;
import com.lcxw.hxzbapi.controller.roomcontroller.RoomRealization;
import com.lcxw.hxzbapi.feign.thirdService.OutRegistService;
import com.lcxw.hxzbapi.service.AddCoinService;
import com.lcxw.hxzbapi.service.AttentionService;
import com.lcxw.hxzbapi.service.AvatarService;
import com.lcxw.hxzbapi.service.ConfigService;
import com.lcxw.hxzbapi.service.CubeDrawRecordService;
import com.lcxw.hxzbapi.service.CubeService;
import com.lcxw.hxzbapi.service.DuanweiService;
import com.lcxw.hxzbapi.service.GiftBagService;
import com.lcxw.hxzbapi.service.GiftSendService;
import com.lcxw.hxzbapi.service.GiftService;
import com.lcxw.hxzbapi.service.GoodNameBuyService;
import com.lcxw.hxzbapi.service.GoodNameService;
import com.lcxw.hxzbapi.service.IncomeService;
import com.lcxw.hxzbapi.service.IncomeTotalService;
import com.lcxw.hxzbapi.service.IncomeUnionService;
import com.lcxw.hxzbapi.service.JubaoService;
import com.lcxw.hxzbapi.service.PhotoService;
import com.lcxw.hxzbapi.service.ProportionService;
import com.lcxw.hxzbapi.service.RealNameAuthService;
import com.lcxw.hxzbapi.service.RichLevelService;
import com.lcxw.hxzbapi.service.RoomRecommendService;
import com.lcxw.hxzbapi.service.TixianService;
import com.lcxw.hxzbapi.service.UnionMemberService;
import com.lcxw.hxzbapi.service.UnionService;
import com.lcxw.hxzbapi.service.VipLevelService;
import com.lcxw.hxzbapi.service.YwpdChargeDetailService;
import com.lcxw.hxzbapi.service.YwpdConsumeService;
import com.lcxw.hxzbapi.service.YwpdMemberService;
import com.lcxw.hxzbapi.service.YwpdRoomService;
import com.lcxw.hxzbapi.service.serviceImpl.AvatarServiceImpl;
import com.lcxw.hxzbapi.service.serviceImpl.ConfigServiceImpl;
import com.lcxw.hxzbapi.service.serviceImpl.GoodNameBuyServiceImpl;
import com.lcxw.hxzbapi.service.serviceImpl.GoodNameServiceImpl;
import com.lcxw.hxzbapi.service.serviceImpl.RoomRecommendServerImpl;
import com.lcxw.hxzbapi.tencentim.FeignService.ImManager;
import com.lcxw.hxzbapi.tencentim.common.TencentImRealization;
import com.lcxw.hxzbcommon.common.RedisUtils;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BeansConfig {

    @Bean
    public YwpdMemberService getYwpdMemberService() {
        return new YwpdMemberService();
    }

    @Bean
    public YwpdRoomService getYwpdRoomService() {
        return new YwpdRoomService();
    }

    @Bean
    public CubeService getCubeService() {
        return new CubeService();
    }

    @Bean
    public GiftService getGiftService() {
        return new GiftService();
    }

    @Bean
    public GiftSendService getGiftEarnService() {
        return new GiftSendService();
    }

    @Bean
    public RichLevelService getRichLevelService() {
        return new RichLevelService();
    }

    @Bean
    public VipLevelService getVipLevelService() {
        return new VipLevelService();
    }

    @Bean
    public DuanweiService getDuanweiService() {
        return new DuanweiService();
    }

    @Bean
    public YwpdChargeDetailService getYwpdChargeDetailService() {
        return new YwpdChargeDetailService();
    }

    @Bean
    public AddCoinService getAddCoinService() {
        return new AddCoinService();
    }

    @Bean
    public RedisUtils getRedisUtils() {
        return new RedisUtils();
    }

    @Bean
    public MemberRealization getMemberRealization() {
        return new MemberRealization();
    }

    @Bean
    public AttentionService getAttentionService() {
        return new AttentionService();
    }

    @Bean
    public TencentImRealization getTencentImRealization() {
        return new TencentImRealization();
    }

    @Bean
    public YwpdConsumeService getYwpdConsumeService() {
        return new YwpdConsumeService();
    }

    @Bean
    public RealNameAuthService getRealNameAuthService() {
        return new RealNameAuthService();
    }

    @Bean
    public UnionService getUnionService() {
        return new UnionService();
    }

    @Bean
    public PhotoService getPhotoService() {
        return new PhotoService();
    }

    @Bean
    public ImManager getImUserManager() {
        return new ImManager() {
            @Override
            public String importAccount(long sdkappid, String identifier, String usersig,
                long random,
                JSONObject requestBody) {
                return null;
            }

            @Override
            public String updateUserInfo(long sdkappid, String identifier, String usersig,
                long random,
                JSONObject requestBody) {
                return null;
            }

            @Override
            public String sendGroupMsg(long sdkappid, String identifier, String usersig,
                long random,
                JSONObject requestBody) {
                String responseData = null;
                try {
                    MediaType JSON = MediaType.parse("application/json; charset=utf-8");
                    RequestBody body = RequestBody.create(JSON, String.valueOf(requestBody));
                    OkHttpClient client = new OkHttpClient();
                    Request request = new Request.Builder()
                        .url(
                            "https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg?sdkappid="
                                + sdkappid + "&identifier=" + identifier + "&usersig=" + usersig
                                + "&random=" + random + "&contenttype=json")
                        .post(body)
                        .build();
                    Response response = client.newCall(request).execute();
                    responseData = response.body().string();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return responseData;
            }

            @Override
            public String destroyGroup(long sdkappid, String identifier, String usersig,
                long random,
                JSONObject requestBody) {
                return null;
            }

            @Override
            public String sendmsg(long sdkappid, String identifier, String usersig, long random,
                JSONObject requestBody) {
                return null;
            }

            @Override
            public String sendAllMember(long sdkappid, String identifier, String usersig, long random, JSONObject requestBody) {
                return null;
            }
        };
    }


    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

//    @Bean
//    public PerformanceInterceptor performanceInterceptor() {
//        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
//        //格式化sql语句
//        Properties properties = new Properties();
//        properties.setProperty("format", "true");
//        performanceInterceptor.setProperties(properties);
//        return performanceInterceptor;
//    }

    @Bean
    public CubeRealization getCubeRealization() {
        return new CubeRealization();
    }


    @Bean
    public GiftBagService getGiftBagService() {
        return new GiftBagService();
    }

    @Bean
    public RoomRealization getCubeRoomRealization() {
        return new RoomRealization();
    }

    @Bean
    public CubeDrawRecordService getCubeDrawRecordService() {
        return new CubeDrawRecordService();
    }

    @Bean
    public UnionMemberService getUnionMemberService() {
        return new UnionMemberService();
    }

    @Bean
    public Qiniu getQiniu() {
        return new Qiniu();
    }

    @Bean
    public OutRegistService getOutRegistService() {
        return new OutRegistService() {
            @Override
            public String OutRegist(JSONObject requestBody) {
                return null;
            }
        };
    }

    @Bean
    public TixianRealization getTixianRealization() {
        return new TixianRealization();
    }

    @Bean
    public TixianService getTixianService() {
        return new TixianService();
    }

    @Bean
    public IncomeService getIncomeService() {
        return new IncomeService();
    }

    @Bean
    public IncomeTotalService getIncomeTotalService() {
        return new IncomeTotalService();
    }

    @Bean
    public IncomeUnionService getIncomeUnionService() {
        return new IncomeUnionService();
    }

    @Bean
    public JubaoService getJubaoService() {
        return new JubaoService();
    }

    @Bean
    public ProportionService getProportionService() {
        return new ProportionService();
    }

    @Bean
    public GoodNameRealization getGoodNameRealization() {
        return new GoodNameRealization();
    }

    @Bean
    public GoodNameService getGoodNameService() {
        return new GoodNameServiceImpl();
    }

    @Bean
    public RoomRecommendService getRoomRecommendService() {
        return new RoomRecommendServerImpl();
    }

    @Bean
    public ConfigService getConfigService() {
        return new ConfigServiceImpl();
    }

    @Bean
    public GoodNameBuyService getGoodNameBuyService() {
        return new GoodNameBuyServiceImpl();
    }

    @Bean
    public AvatarService getAvatarService() {
        return new AvatarServiceImpl();
    }
}
